package com.pzhu.mapper;

import com.pzhu.model.entity.Staff;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pzhu.model.vo.StaffDateVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Administrator
* @description 针对表【hs_staff(工作人员)】的数据库操作Mapper
* @createDate 2023-12-16 22:51:28
* @Entity com.pzhu.model.entity.Staff
*/
public interface StaffMapper extends BaseMapper<Staff> {

    @Select(" select\n" +
            "        si.id as id,username,photo,star,count(1) as count\n" +
            "        FROM `hs_staff` si ,`hs_bookable` b\n" +
            "        WHERE si.id = b.staff_id AND DATE_FORMAT(start_time,'%Y-%m-%d') = #{date} AND start_time >= NOW()\n" +
            "        GROUP BY id")
    List<StaffDateVo> getByDate(String date);


    @Select("SELECT s.username,s.age,s.education,s.star,s.experience,wage,count(o.id) AS count  from hs_staff s \n" +
            "            LEFT JOIN hs_wage w ON s.job_number = w.job_number LEFT JOIN hs_order o ON w.staff_id = o.staff_id \n" +
            "           GROUP BY s.id,wage\n" +
            "\t\t\t\t\tORDER BY RAND()  LIMIT 5")
    List<Staff> compare();

}




